# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        Young  
# Name:         demo4.29
# Description:
# Author:       asus
# Date:         2019/1/18
#-------------------------------------------------------------------------------


print('---测试append方法---')
numbers = [1,2,3,4]
numbers.append(5)
print(numbers)
numbers.append([6,7])
print(numbers)

print('---测试clear方法---')
names = ["Bill","Marry","Jack"]
print(names)
names.clear()
print(names)

print('---测试copy方法---')
a = [1,2,3]
b = a
b[1] = 30
print(a)
aa = [1,2,3]
bb = aa.copy()
bb[1] = 30
print(aa)

print('---测试count方法---')
search = ["he","new","he","he","world","peter","[1,2,3]","ok","[1,2,3]"]
# 搜索"he"在search中出现的次数
print(search.count("he"))
# 搜索[1,2,3]在search中出现的次数
print(search.count("[1,2,3]"))

print('---测试extend方法---')
a = [1,2,3]
b = [4,5,6]
a.extend(b)
print(a)

a = [1,2,3]
b = [4,5,6]
print(a+b)

a = [1,2,3]
b = [4,5,6]
a[len(a):]=b
print(a)

print('---测试index方法---')
s = ["I","love","python"]
print(s.index("python"))

print('---测试insert方法---')
numbers = [1,2,3,4,5]
numbers.insert(3,"four")
print(numbers)

numbers = [1,2,3,4,5]
numbers[3:3]=["four"]
print(numbers)

print('---测试pop方法---')
numbers = [1,2,3]
print(numbers.pop())
print(numbers.pop(0))
print(numbers)

print('---测试remove方法---')
words = ["he","new","he","yes","bike"]
words.remove("he")
print(words)

print('---测试reverse---')
numbers = [1,2,3,4,5,6]
numbers.reverse()
print(numbers)

print('---测试sort方法---')
# 混合数据不能
numbers = [5,4,1,7,4,2]
numbers.sort()
print(numbers)

x = [5,4,1,7,4,2]
y = x[:]
y.sort()
print(x)
print(y)

x = [7,6,4,8,5]
y = sorted(x)
print(x)
print(y)


